export function http(param) {
	var url = param.url,
		method = param.method,
		header = {},
		data = param.data || {};
		
	var requestUrl = 'http://192.168.177.1:8081/database' + url;

	header = {
		'content-type': "application/json",
		'token': uni.getStorageSync('token')
	};

	return uni.request({
		url: requestUrl,
		data: data,
		method: method,
		header: header,
	}).then(res => {
		if (res[1].statusCode == 405) {
			uni.navigateTo({
				url: '/pages/user/login'
			})
			uni.showToast({
				title: '登录过期',
				icon: 'error'
			});
			return;
		}
		
		if (res[1].data.code == 401) {
			uni.showToast({
				title: "账号密码错误",
				icon: 'error'
			});
			return;
		} else if (res[1].data.code == 400) {
			uni.showToast({
				title: res[1].data.msg,
				icon: 'error'
			});
			return;
		}
		
		// 将结果抛出
		return res[1].data
	})
}
